<!DOCTYPE html>
<html class="x-admin-sm">
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.1</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="__ADMIN__/css/font.css">
    <link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
    <script type="text/javascript" src="__ADMIN__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__/js/xadmin.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/cookie.js"></script>
    <style>
        .layui-form-item .layui-form-label{
            width: 120px;
        }
        .layui-form-item .layui-textarea{
            width: 190px;
        }
    </style>
    <script type="text/javascript">

  </script>
  </head>
  
  <body>
    <div class="x-body">
        <form class="layui-form">
            <input type="hidden" name="id" value="{$clients.id}" />
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                 赛事名称
              </label>
              <label for="name" class="layui-form-label" style="text-align:left;">
                  {$clients.activity}
              </label>
          </div>
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                 客户
              </label>
              <label for="name" class="layui-form-label" style="text-align:left;">
                  {$clients.name}
              </label>
          </div>
          <div class="layui-form-item">
            <label for="username" class="layui-form-label">
              合同图片
            </label>
            <div class="layui-input-block">
                <button type="button" style="width: 140px;" class="layui-btn layui-btn-sm layui-btn-normal" id="uploads"><i class="layui-icon">&#xe67c;</i>批量上传</button>
                <!--<img id="img" src="" width="140px" style="margin-top: 5px;display: block;">-->
                <!--<input type="hidden" name="hetong" id="hetong" value=""  />-->
                <div id="hetong_box">
                    
                    
                </div>
            </div>
          </div>
          
          <div class="layui-form-item">
            <label for="username" class="layui-form-label">
              聊天记录图片
            </label>
            <div class="layui-input-block">
                <button type="button" style="width: 140px;" class="layui-btn layui-btn-sm layui-btn-normal" id="uploads_"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                <img id="img_" src="" width="140px" style="margin-top: 5px;display: block;">
                <input type="hidden" name="chat_img" id="chat_img" value="" />
            </div>
          </div>
          <div class="layui-form-item">
              <label for="company_name" class="layui-form-label">
                  聊天记录说明
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="chat_remark" name="chat_remark" placeholder="如上传聊天记录截图，请详细说明"  autocomplete="off" class="layui-input">
              </div>

          </div>
          
          <!-- <div class="layui-form-item">
              <label for="live_id" class="layui-form-label">
                  <span class="x-red">*</span>直播id
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="live_id" name="live_id" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>海豚直播后台创建链接后的链接id
              </div>
          </div> -->

          <div class="layui-form-item">
              <label for="company_name" class="layui-form-label">
                  <span class="x-red">*</span>公司名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="company_name" name="company_name" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>

          </div>
          <div class="layui-form-item">
              <label for="ratio" class="layui-form-label">
                  <span class="x-red">*</span>合作分成
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="ratio" name="ratio" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>

          </div>
          <div class="layui-form-item">
              <label for="cashing_fee" class="layui-form-label">
                  <span class="x-red">*</span>提现手续费
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="cashing_fee" name="cashing_fee" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>

          </div>
          <div class="layui-form-item">
              <label for="company_address" class="layui-form-label">
                  <span class="x-red">*</span>直播机位<br>(照片直播)
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="company_address" name="company_address"  placeholder="详情..." required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>

          </div>




          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  确定签单
              </button>
          </div>
      </form>
    </div>
    <script>
    layui.use(['form','layer','laydate','upload'], function(){
          $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer
          ,laydate = layui.laydate
          ,upload = layui.upload;


          var uploadInst = upload.render({
              elem: '#uploads'
              , url: '{:url("Client/upload")}'
              , multiple: true
              , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result){
                    $('#hetong_box').append('<img src="'+result+'" width="140px" style="margin-top: 5px;display: block;">');
                    
                    // var img=$("#img").attr("src");
                    // var imgurl=$("#hetong").val();
                    // if(img){
                    //     $.ajax({
                    //         type:"post",
                    //         dataType:"json",
                    //         data:{imgurl:imgurl},
                    //         url:"{:url('Client/cancel')}",
                    //         success:function(data){
                    //         }
                    //     });
                    // }
                    // $('#img').attr('src', result); 
                });
              }
              , done: function (res) {
                  //如果上传失败
                  if (res.code == 0) {
                      return layer.msg(res.err);
                  }
                  //上传成功
                  if(res.code == 1) {
                      $('#hetong_box').append('<input type="hidden" name="hetong[]" value="'+res.savename+'"  />');
                      //$('#hetong').attr('value','/uploads/hetong/'+res.savename);
                  }
              }
          });
          var uploadInst = upload.render({
              elem: '#uploads_'
              , url: '{:url("Client/upload")}'
              , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result){
                    //如果有图片再点击上传就撤销原来的图片
                    var img=$("#img_").attr("src");
                    var imgurl=$("#chat_img").val();
                    if(img){
                        $.ajax({
                            type:"post",
                            dataType:"json",
                            data:{imgurl:imgurl},
                            url:"{:url('Client/cancel')}",
                            success:function(data){
                            }
                        });
                    }
                    $('#img_').attr('src', result); //图片链接(base64)
                });
              }
              , done: function (res) {
                  //如果上传失败
                  if (res.code == 0) {
                      return layer.msg(res.err);
                  }
                  //上传成功
                  if(res.code == 1) {
                      $('#img_').attr('src','/uploads/hetong/'+res.savename);
                      $('#chat_img').attr('value','/uploads/hetong/'+res.savename);
                  }
              }
          });
          //监听提交
        form.on('submit(add)', function(data){
            if($('#hetong').val() || ($('#chat_img').val() && $('#chat_remark').val() )  )
            {
                $.ajax({
                    type:'POST',
                    dataType:'json',
                    data:{data:data.field},
                    url:"{:url('Client/qian')}",
                    success:function(obj){
                      layer.msg(obj.msg, {icon: obj.icon,time: 2000},function(){
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        // 可以对父窗口进行刷新 
                        x_admin_father_reload();
                      });
                    }
                });
                return false;
            }
            else
            {
                layer.alert('请上传合同图片或聊天记录+说明');
                return false;
            }
        });
    });
    </script>
  </body>

</html>